import crypto.aes
import crypto.rand

fn main() {
    // remember to save this key somewhere if you ever want to decrypt your data
    key := rand.bytes(32)?
    println('KEY: $key')

    // this data is one block (16 bytes) big
    mut data := 'THIS IS THE DATA'.bytes()

    println('generating cipher')
    cipher := aes.new_cipher(key)

    println('performing encryption')
    mut encrypted := []u8{len: aes.block_size}
    cipher.encrypt(mut encrypted, data)
    println(encrypted)

    println('performing decryption')
    mut decrypted := []u8{len: aes.block_size}
    cipher.decrypt(mut decrypted, encrypted)
    println(decrypted)

    assert decrypted == data
}
